package com.market.plus.core.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@Table(name = "USERINFO")
@NamedQueries( { 
   @NamedQuery(name = UserInfo.FIND_BY_USERNAME, query = "SELECT userInfo FROM UserInfo userInfo WHERE userInfo.username=:username")})
public class UserInfo implements Persistable {

   public static final String FIND_BY_USERNAME = "UserInfo.FIND_BY_USERNAME";
   public static final String PARA_USERNAME = "username";

   @Id
   @GeneratedValue(strategy = GenerationType.TABLE, generator = "GEN_USERINFO")
   @TableGenerator(name = "GEN_USERINFO", table = "SEQUENCE_LIST", allocationSize = 1, initialValue = 1, pkColumnName = "NAME", valueColumnName = "NEXT_SEQUENCE", pkColumnValue = "USERINFO")
   @Column(name = "USERINFO_ID")
   private Long id;

   @Column(name="USERNAME", nullable=false)
   private String username;

   @Column(name="EXTERNALID", nullable=false, unique=true)
   private String externalId;

   @OneToOne(mappedBy="userInfo")
   private Participant participant;

   @Column(name = "STATUS")
   @Enumerated(EnumType.ORDINAL)
   private Status status;

   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public String getUsername() {
      return username;
   }

   public void setUsername(String username) {
      this.username = username;
   }

   public String getExternalId() {
      return externalId;
   }

   public void setExternalId(String externalId) {
      this.externalId = externalId;
   }

   public Participant getParticipant() {
      return participant;
   }

   public void setParticipant(Participant participant) {
      this.participant = participant;
   }

   public Status getStatus() {
      return status;
   }

   public void setStatus(Status status) {
      this.status = status;
   }
}
